<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
	var xhr;
	function createXMLHttpRequest() {
		if (window.ActiveXObject) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			xhr = new XMLHttpRequest();
		}
	}
	function idPasswordCheck() {
		//1. xhr 생성
		createXMLHttpRequest();
		var url = "/hansot/login.do?memberId="
				+ document.getElementById("loginId").value + "&password="
				+ document.getElementById("loginPassword").value;
		//처리를 요청
		alert(url);
		xhr.onreadystatechange = checkIdPassword;
		xhr.open("GET", url, true);
		xhr.send(null);
	}
	//callback 함수
	function checkIdPassword() {
		//응답이 끝났으면
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var txt = xhr.responseText;
				alert(txt);
			} else {
				alert("처리 도중 오류 발생 : " + xhr.status);
			}
		}
	}

	function formCheck() {
		var form = window.document.login;
		if (!form.loginId.value) {
			alert("아이디를 넣으세요");
			form.loginId.focus();
			return false;
		}
		if (!form.loginPassword.value) {
			alert("패스워드를 넣으세요");
			form.loginPassword.focus();
			return false;
		}
	}
	
</script>


<c:if test="${requestScope.error_message != null }">
	<script type="text/javascript">
		alert("${requestScope.error_message }");
	</script>
</c:if>

	<c:choose>
		<c:when test="${sessionScope.login_info.memberId == null }">
			<b>LOGIN</b>
			<hr>
			<form method="post" action="login.do" name="login" id="login"
				onsubmit="return formCheck();">
				<table>
					<tr>
						<td>ID :</td>
						<td><input type="text" name="loginId" id="loginId" size="10"></td>
					</tr>
					<tr>
						<td>Password :</td>
						<td><input type="password" name="loginPassword"
							id="loginPassword" size="10"></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input type="submit"
							value="로그인" id="loginBtn"> <a href="registerForm.do"><input
								type="button" value="회원가입"></a><br></td>
					</tr>
				</table>
			</form>

			<!-- 
			<hr>
			<a href="">아이디 찾기</a>
			<br>
			<a href="">비밀번호 찾기</a>
			<br>-->
		</c:when>
		<c:otherwise>
	
		${sessionScope.login_info.memberId }님 반갑습니다.<br>
			<hr>
			<a href="logout.do"><input type="button" value="로그아웃"></a>
			<a href="memberUpdate.do"><input type="button" value="정보수정"></a><br>
			
			

		</c:otherwise>
	</c:choose>

